package com.mgl.movesprite.game.factory;

import org.andengine.entity.sprite.AnimatedSprite;
import org.andengine.entity.sprite.Sprite;

import com.mgl.movesprite.CloseButton;
import com.mgl.movesprite.EntitySpriteLevelBase;
import com.mgl.movesprite.game.model.Background;
import com.mgl.movesprite.game.model.BeginPoint;
import com.mgl.movesprite.game.model.BuildZone;
import com.mgl.movesprite.game.model.EndPoint;
import com.mgl.movesprite.game.model.Monster;
import com.mgl.movesprite.game.model.Shot;
import com.mgl.movesprite.game.model.TowerFire;
import com.mgl.movesprite.game.model.TowerWater;
import com.mgl.movesprite.game.model.Wave;
import com.mgl.util.ButtonSprite;
import com.mgl.util.GameGeneralSprite;
public class GameObjectFactory {

	private GameTextureManager gameTextureManager = null;

	public GameObjectFactory(GameTextureManager gameTextureManager) {

		this.gameTextureManager = gameTextureManager;

	}

	public Sprite createObject(GameType type, float px, float py) {

		Sprite object = null;
		
		switch (type) {
		// towers
		// -------------------------------------------------------------------------------
		case BUILD_ZONE:

			object = new BuildZone(px, py,
					gameTextureManager.getBuildZoneTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);

			break;
		case TOWER_WATER:
			object = new TowerWater(px, py, gameTextureManager.getTowerWaterTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);
					System.out.println("tower Water");
			break;
		case TOWER_FIRE:

			object = new TowerFire(px, py, gameTextureManager.getTowerFireTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);
			System.out.println("tower Fire");
			break;
		// towers
		// --------------------------------------------------------------------------------
		// monsters
		// --------------------------------------------------------------------------------
		case WAVE:
			object = new Wave(px, py,
					gameTextureManager.getBeginPointTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);
			break;
		case MONSTER:
						
			object = new Monster(px,py,gameTextureManager.getMonsterITextureRegion(),gameTextureManager.getVertexBufferObjectManager(),this);

			break;
		// monsters
		// ---------------------------------------------------------------------------
		// background
		// level--------------------------------------------------------------------
		case BACKGROUND_LEVEL1:

			object = new Background(px, py,
					gameTextureManager.getBackgroundTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);

			break;
		// background
		// level--------------------------------------------------------------------
		// shots
		// ------------------------------------------------------------------------------
		case SHOT:
			object = new Shot(px, py,
					gameTextureManager.getBeginPointTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);
			break;
		// shots
		// ------------------------------------------------------------------------------
		// general
		// ------------------------------------------------------------------------------
		case BEGIN_POINT:

			object = new BeginPoint(px, py,
					gameTextureManager.getBeginPointTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);

			break;
		case END_POINT:

			object = new EndPoint(px, py,
					gameTextureManager.getBeginPointTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);
			break;

		case PANEL_BACKGROUND:
			object = new EndPoint(px, py,
					gameTextureManager.getBlackBackgroundTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);
			break;
			
		case RADIO:

			object = new GameGeneralSprite(px, py,
					gameTextureManager.getRadioTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);
			object.setAlpha((float) 0.4);
			break;

			
		//BUTTONS --------------------------------------------------------------------
		case CLOSE_BUTTON:
			object = new CloseButton(px, py,
					gameTextureManager.getCloseButtonTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);
			break;
		case NEXT_BUTTON:
			object = new ButtonSprite(px, py,
					gameTextureManager.getNextButtonTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);
			break;
		case PREV_BUTTON:
			object = new ButtonSprite(px, py,
					gameTextureManager.getPrevButtonTexture(),
					gameTextureManager.getVertexBufferObjectManager(), this);
			break;
		default:
			System.out
					.println("No encontre el tipo en ObjectFactory : " + type);
			break;
		}
		
		return object;
	}

	public GameTextureManager getGameTextureManager() {
		return gameTextureManager;
	}

	public void setGameTextureManager(GameTextureManager gameTextureManager) {
		this.gameTextureManager = gameTextureManager;
	}

}
